// $codepro.audit.disable declareAsInterface
/**Medical History presenter**/
package edu.gatech.presenters;

import java.util.ArrayList;

import javax.swing.JTextArea;

import edu.gatech.datastorage.TreatmentRecord;
import edu.gatech.userclasses.Patient;

/** Calculates medical history for a patient
 * 
 * @author Tyler Natoli
 * @version 1.0
 */
public class MedicalHistoryPresenter {
	
	/**Record being displayed**/
	private TreatmentRecord record;
	
	/**Patient whose medical history being looked at**/
	private final Patient currentPatient;
	
	/** Constructor for creating medical history
	 * 
	 * @param record
	 * @param currentPatient
	 */
	public MedicalHistoryPresenter(TreatmentRecord record, Patient currentPatient){
		this.record = record;
		this.currentPatient = currentPatient;
	}
	
	/** Updates the treatment record being displayed
	 * 
	 * @param selectedRecord
	 * @param field
	 */
	public void updateRecordDisplay(String selectedRecord, JTextArea field){
		final ArrayList<TreatmentRecord> list = 
			(ArrayList<TreatmentRecord>) currentPatient.getInfo().getHistory();
		for(int i = 0; i < list.size(); i++){
			if(selectedRecord.equals(list.get(i).getAppointment().getDate())){
				record = list.get(i); 
			}
				
		}
		field.setText(record.toString());
	}
	
	/**Overrides toString
	 * @return String
	 */
	public String toString(){
		return "Medical history presenter";
	}
}
